<template>
  <div class="home-container">
    <li
      class="brick-item brick-item-m brick-item-m-2"
      v-for="(item, index) in productData.data"
      :key="index"
    >
      <a @click="goToProductDetail(item.id)" target="_blank">
        <div class="figure figure-img">
          <img
            width="160"
            height="160"
            :alt="item.name"
            :src="item.image"
            lazy="loaded"
          />
        </div>
        <h3 class="title">{{ item.name }}</h3>
        <p class="desc">{{ item.description }}</p>
        <p class="price">
          <span class="num">{{ item.price }}</span>
          元
          <span></span>
        </p>
      </a>
    </li>
  </div>
</template>

<script>
export default {
  name: 'ProductBrick',
  props: {
    productData: {
      type: Object,
      required: true,
    },
  },
  methods: {
    goToProductDetail(id) {
      this.$router.push({ name: 'ProductDetail', params: { id } })
    },
  },
}
</script>

<style scoped>
a {
  background-color: rgba(0, 0, 0, 0);
  text-decoration: none; /* 默认不下划线 */
}
a:active,
a:hover {
  outline: 0;
}

.home-brick-box {
  margin-bottom: 8px;
}

.home-brick-box .box-hd .more .tab-list li {
  margin: 0 0 0 30px;
}

.home-brick-box .brick-list,
.home-brick-box .brick-promo-list {
  margin: 0 0 -14px -14px;
}

.home-brick-box .tab-content-hide {
  display: none;
}

.brick-list,
.brick-promo-list {
  height: 614px;
  margin: 0;
  padding: 0;
  list-style-type: none;
}

.brick-list {
  width: 992px;
}

.brick-promo-list a {
  display: block;
  width: 100%;
  height: 100%;
}

.brick-promo-list img {
  width: 234px;
}

.brick-promo-list .brick-item-l img {
  height: 614px;
}

.brick-promo-list .brick-item-m {
  height: 300px;
  padding: 0;
}

.brick-promo-list .brick-item-m img {
  height: 300px;
}

.brick-promo-list .brick-item-s img {
  height: 143px;
}

.brick-item {
  position: relative;
  z-index: 1;
  float: left;
  width: 234px;
  margin-left: 14px;
  margin-bottom: 14px;
  background: #fff;
  -webkit-transition: all 0.2s linear;
  transition: all 0.2s linear;
}

.brick-item:hover {
  z-index: 2;
  -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  -webkit-transform: translate3d(0, -2px, 0);
  transform: translate3d(0, -2px, 0);
}

.brick-item-l {
  height: 614px;
}

.brick-item-m {
  height: 246px;
  padding: 34px 0 20px;
}

.brick-item-m .figure-img {
  width: 150px;
  height: 150px;
  margin: 0 auto 18px;
}

.brick-item-m .figure-img a {
  display: block;
}

.brick-item-m .figure-img img {
  width: 150px;
  height: 150px;
}

.brick-item-m .title {
  margin: 0 10px;
  font-size: 14px;
  font-weight: 400;
  color: #333;
}

.brick-item-m .desc,
.brick-item-m .title {
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.brick-item-m .desc {
  margin: 0 10px 10px;
  height: 18px;
  font-size: 12px;
  color: #b0b0b0;
}

.brick-item-m .price {
  margin: 0 10px 10px;
  text-align: center;
  color: #ff6700;
}

.brick-item-m .price del {
  margin-left: 0.5em;
  color: #b0b0b0;
}

.brick-item-m-2 {
  height: 300px;
  padding: 0;
}

.brick-item-m-2 > a {
  display: block;
  height: 100%;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  padding: 20px 0;
}

.brick-item-m-2 .figure-img,
.brick-item-m-2 .figure-img img {
  width: 160px;
  height: 160px;
}

.brick-item-m-2 .title {
  margin: 0 10px 2px;
}

.brick-item-m-2 .price {
  margin: 0 10px 14px;
}
</style>
